﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="EditResource.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Admin.EditResource" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
    <script type="text/javascript">
        $(document).ready(function(){
            
            $("#frmResource").validate({
           rules: {
             Caption: "required",
             Url: "required"
           },
           errorLabelContainer:"#frmResourceErr",
           messages: {
             Caption: "Please enter a caption.",
             Url: "Please enter a web address."
           }
        });
        
        });
    </script>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <% LBRDataContext dc = new LBRDataContext();  %>
    <% Resource r = dc.GetResource(int.Parse(ViewData["ResourceId"].ToString()));
       if (r == null) r = new Resource();
       object vals = new {id = r.ResourceId };  
    %>
    <div class="contentDiv" style="margin-left:15%; margin-top:20px">
        <form method="post" id="frmResource" enctype="multipart/form-data" action="<%= Url.Action("SaveOrUpdateResource", "Admin", vals ) %>" >
            <fieldset id="fldRegister" style="width:500px;display:block;">
                <legend><%= r.ResourceId == 0 ? "New" : "Edit" %> Resource</legend>
                <table>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="txtUserName">Caption:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("Caption", r.Caption, new { style = "width:300px" })%></td>
                </tr>
                <tr class="addPropertyRow">
                    <td class="addPropertyLabel"><label class="label" for="txtUserName">Link:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.TextBox("Url", r.Url, new { style = "width:400px" })%></td>
                </tr>
                <tr>
                    <td class="addPropertyLabel"><label class="label" for="txtPrivate">Private:&nbsp;</label></td>
                    <td class="addPropertyField"><%= Html.CheckBox("Private", r.Private)%></td>
                </tr>
                <tr>
                    <td colspan="2"><div id="frmResourceErr" class="ValidateErrorContainer"></div></td>
                </tr>
                </table>
            </fieldset>
            <div style="display:inline">
                <input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
                <button onclick="window.location='../Admin.ashx/ResourceList'; return false;">Cancel</button>
            </div>
        </form>
    </div>
</asp:Content>
